<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:cc="http://java.sun.com/jsf/composite/cc"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="/resources/layout/training-layout.xhtml">
   
    <ui:define name="head">
	</ui:define>
    <ui:define name="toolbar">
        <h:form prependId="false">
            <p:menubar widgetVar="t">
                <c:forEach items="#{racesController.menu.subMenus}" var="subMenu" varStatus="subMenuStatus">
                    <p:submenu label="#{subMenu.text}">
                        <c:forEach items="#{subMenu.menuItems}" var="menuItem" varStatus="menuItemStatus">
                            <p:menuitem value="#{menuItem.text}"  url="#{menuItem.url}" />
                        </c:forEach>
                    </p:submenu>
                </c:forEach>
            </p:menubar>
        </h:form>
    </ui:define>
	<ui:define name="content">
        <p:growl showDetail="true" showSummary="true" />
        <h:form prependId="false" id="racesForm">
        <p:dataGrid value="#{racesController.dataModel.rows}" var="row" columns="1">
            <p:column>
                <p:panel>
                    <h:panelGrid columns="10">
                        <p:graphicImage value="#{row.object.new ? '../resources/images/new.png' : '../resources/images/bullet_white.png'}" />
                        <h:outputText value="[#{row.object.district.code}]"/>
                        <h:outputText value="#{row.object.name}"/>
                        <h:outputText value="#{row.object.date}"><f:convertDateTime timeStyle="medium" type="date"/></h:outputText>
                        <h:commandLink id="lc01" action="#{racesController.view}" value="Detail">
                            <f:setPropertyActionListener value="#{row.object}" target="#{sessionController.race}" />
                        </h:commandLink>
                        <h:commandLink id="lc02" action="#{racesController.register}" value="Register" rendered="#{sessionController.loggedIn}">
                            <f:setPropertyActionListener value="#{row.object}" target="#{sessionController.race}" />
                        </h:commandLink>
                    </h:panelGrid>
                </p:panel>
            </p:column>
        </p:dataGrid>
        </h:form>
	</ui:define>
</ui:composition>
